home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9184 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  52 lines

  1. Path: news.mira.net.au!news
  2. From: davidw@werple.net.au (David White)
  3. Newsgroups: comp.lang.c++,gnu.g++.help
  4. Subject: Re: Forward declarations of typedefs
  5. Date: 29 Feb 1996 20:07:47 +1100
  6. Organization: Werple Internet, Melbourne
  7. Message-ID: <4h3qd3$esa@werple.net.au>
  8. References: <4h2fhp$si8@elaine22.Stanford.EDU>
  9. NNTP-Posting-Host: werple.mira.net.au
  10.  
  11. iburrell@leland.Stanford.EDU (Ian Burrell) writes:
  12.  
  13. >I am trying to do a forward declaration of a type defined in another
  14. >header so that I can make a class member that is a pointer.  However,
  15. >if the forward declaration type is later defined as a typedef, I get
  16. >lots of errors.
  17.  
  18. >Is there a way to consistently make forward declarations that works
  19. >with later typedefs?  Does the method work if the type representation
  20. >later changes?  How about anonymous structs defined in a typedef?
  21.  
  22. >Here is a snippet of example code and the errors it gives:
  23.  
  24. >struct test;
  25.  
  26. >test* t;
  27.  
  28. >struct _test
  29. >{
  30. >    int a;
  31. >};
  32.  
  33. >typedef _test test;
  34.  
  35. 'test' cannot be declared as both a struct in its own right and an alias 
  36. for 'struct _test'. The only struct here is '_test', not 'test'.
  37. It is not necessary to have '_test', e.g., 
  38.  
  39. //In one header
  40. struct test
  41. {
  42.     int a;
  43. };
  44.  
  45. //In the other
  46. struct test;
  47.  
  48. test *t;
  49.  
  50. David White
  51. davidw@werple.mira.net.au
  52.